import { http } from "@/utils/http";
/**
 * 用户列表
 * @param data keyWord
 * @return
 */
export const getUserList = (data?: any) => {
  return http.request("post", "/admin/user/user/list", { data });
};

/**
 * 用户详情
 * @param userId 用户id
 * @return
 */
export const getUserDetail = (userId: number) => {
  return http.request("post", "/admin/user/user/info", {
    data: { userId }
  });
};

/**
 * 编辑用户信息
 * @param data userId money, score, status = normal, hidden
 * @return
 */
export const setUser = (data?: any) => {
  return http.request("post", "/admin/user/user/set", { data });
};

/**
 * 充值列表
 * @param data page PageSize
 * @return
 */
export const getChargeList = (data?: any) => {
  return http.request("post", "/admin/user/recharge/list", { data });
};

/**
 * 处理充值
 * @param data rechargeId  status notes
 * @return
 */
export const handleCharge = (data?: any) => {
  if (data?.notes == null) {
    data.notes = "";
  }
  return http.request("post", "/admin/user/recharge/handle", { data });
};

/**
 * 提现列表
 * @param data page pageSize status startTime endTime keyWord
 * @return
 */
export const getWithdrawList = (data?: any) => {
  return http.request("post", "/admin/user/out/list", { data });
};

/**
 * 处理提现
 * @param status 状态(状态:0=待审核,1=已通过,2=驳回)
 * @param remark 备注
 * @param cIds []列表
 * @return
 */
export const handleWithdraw = (data?: any) => {
  if (data?.remark == null) {
    data.remark = "";
  }
  return http.request("post", "/admin/user/out/handle", { data });
};

/**
 * 用户统计数据
 * @param userId 用户id
 * @return
 */
export const getUserCountInfo = (userId: number) => {
  return http.request("post", "/admin/user/count/info", { data: { userId } });
};
/**
 * 用户团队数据
 * @param uId 用户id  startTime  endTime 无分页
 * @return
 */
export interface UserTeamDataItem {
  id: number; // 用户id
  account: string; // 账号
  createdAt: string; // 注册时间
  teamNum: number; // 团队人数
  teammoney: string; // 团队总充值
  mymoney: string; // 团队总积分
}
export interface UserTeamData {
  teamNum: number; // 团队人数
  teammoney: string; // 团队总充值
  mymoney: string; // 团队总积分
  userZTList: UserTeamDataItem[]; // 团队列表
}
export const getUserTeamList = (data?: any) => {
  return http.request<UserTeamData>("post", "/admin/user/team/list", { data });
};

/**
 *
 * @returns 发放分红
 */
export const doPartner = (hhrAmount: number) => {
  return http.request("post", "/admin/user/hhr/partner", {
    data: { hhrAmount }
  });
};
/**
 *
 * @returns 取消分红分红
 */
export const cancelPartner = (relId: number) => {
  return http.request("post", "/admin/user/hhr/cancel", {
    data: { relId }
  });
};
/**
 * 获取用户实名认证数据
 * @param data 可能需要的请求参数
 * @return 返回用户实名认证相关数据
 */
export class UserIdAuthData {
  id: number; // 用户ID
  name: string; // 用户姓名
  card: string; // 用户身份证号
  zmimage: string; // 身份证正面图片地址
  bmimage: string; // 身份证背面图片地址
  status: string; // 实名认证状态
  createdAt: string; // 认证时间
}

export const getUserIdAuthData = (uId: number) => {
  return http.request<UserIdAuthData>("post", "/admin/user/user/smrz", {
    data: { uId }
  });
};

/**
 * 个人流水记录
 * @param uId page pageSize type orderId wallet thisMonth
 * @return
 */
export const getFlowList = (data?: any) => {
  return http.request("post", "/admin/user/flow/list", { data });
};

/**
 * 更新用户密码
 */
export const setUserPwd = (data?: any) => {
  return http.request("post", "/admin/user/reset/pwd", { data });
};
